﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NOAH.CMS.Cache;
using NOAH.CMS.Repository;

public partial class Registration_Step1 : System.Web.UI.Page
{
    string subjectId = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        subjectId = Request.QueryString["id"] ?? "0";

        BindSubjects();

        BindCourses();
    }

    private void BindSubjects()
    {
        //List<Subject> subjects = new SubjectCacheLayer().GetAll().OrderBy(p => p.Name).ToList();
        //subjects.Add(new Subject { Name = "Tất cả", ID = 0 });

        //rptSubjects.DataSource = subjects;

        //rptSubjects.DataBind();
    }


    private void BindCourses()
    {
        CourseRepository repository = new CourseRepository();
        List<Course> courses = new List<Course>();
        if (subjectId == "0")
        {
            courses = repository.GetAll();
        }
        else
        {
            courses = repository.GetCourseBySubject(int.Parse(subjectId));
        }

        rptCourses.DataSource = courses;
        rptCourses.DataBind();
    }


}